package networkSimulation.statistic

import networkSimulation.framework.{Edge, Node, Graph}

/**
 * Abstract class to represent a statistic
 *
 * @author  Tim Caljé
 *          Jeroen De Raedt
 *          Jorick Van Aken
 */
abstract class Statistic[N<%Node,E<%Edge[N]](){
  var amountsEdges = List[Int]()
  var amountsNodes = List[Int]()
  private var edges = 0
  private var nodes = 0
  var key = ""

  /*
  *  Generate the visual statistic
  */
  def generateStatistic(vis: VisualStatistics,path : String)

  /*
  *  Take snapshots from the graph
  */
  def updateStatistics(graph: Graph[N, E],k:String){
    nodes = graph.nodes.size
    edges = graph.edges.size
    this.key = k
  }

  /*
  *  Load the xml data into the statistic
  */
  def loadData(data : xml.NodeSeq){
      amountsNodes ::= (data \\ "AmountNodes").text.toInt
      amountsEdges ::= (data \\ "AmountEdges").text.toInt
  }

  /*
  *  Generates xml for the statistic
  */
  def toXml(): xml.NodeSeq  = {
    <Stat key={key}>
      <AmountNodes>{ nodes }</AmountNodes>
      <AmountEdges>{ edges }</AmountEdges>
    </Stat>
  }
}